#include "worldgridmanager.h"

#include "terraingeneratorlibnoise.h"
#include "terraingeneratorsimplex.h"

namespace infinity {

WorldGridManager::WorldGridManager()
:	m_planet(NULL)
{
	// m_planet = Planet::load("./savegame.ip");

	if(!m_planet)
	{
		// TerrainGenerator* generator = new TerrainGeneratorLibNoise(512, 64, -64);
		TerrainGenerator* generator = new TerrainGeneratorSimplex(64, 8);

		m_planet = new Planet(generator, 64);
	}
}

WorldGridManager::~WorldGridManager()
{
	delete m_planet;
}

void WorldGridManager::initialize()	
{
	m_planet->install();
}

Planet* WorldGridManager::getPlanet()
{
	return m_planet;
}

const Planet* WorldGridManager::getPlanet() const
{
	return m_planet;
}

void WorldGridManager::getCell(dw::int32 x, dw::int32 y, dw::int32 z, Planet::Cell& cell) const
{	
	m_planet->getCell(Vector3i(x, y, z), cell);
}

void WorldGridManager::setCell(dw::int32 x, dw::int32 y, dw::int32 z, const Planet::Cell& cell)
{	
	m_planet->setCell(Vector3i(x, y, z), cell);
}

} // namespace infinity
